<template>
	<div class="checkException">
		<el-breadcrumb class="breadcrumb" separator="/">
			<el-breadcrumb-item :to="{ path: '/check' }">我的审核</el-breadcrumb-item>
			<el-breadcrumb-item>通融审批</el-breadcrumb-item>
		</el-breadcrumb>
		<div class="info-content">
			<steps ref="steps"></steps>
			<hr class="hr">
			<div class="title">客户信息</div>
			<div class="infoContent">
				<el-row class="info-row">
					<el-col :span="8" class="info-label">
						订单编号：
						<router-link :to="{path:'/loanApplyDeal?orderNo='+orderNo + '&annexBatchNo='+annexBatchNo+'&customerIdCard='+customerIdCard+'&orderStatus='+orderStatus}">
							<label class="text active">{{customerInfo.orderNo}}</label>
						</router-link>
					</el-col>
					<el-col :span="8" class="info-label">
						业务员：
						<label class="text">{{customerInfo.salesman}}</label>
					</el-col>
					<el-col :span="8" class="info-label">
						业务部门：
						<label class="text">{{customerInfo.salesmanUnit}}</label>
					</el-col>
				</el-row>
				<el-row class="info-row">
					<el-col :span="8" class="info-label">
						客户姓名：
						<label class="text">{{customerInfo.customer}}</label>
					</el-col>
					<el-col :span="8" class="info-label">
						申请日期：
						<label class="text">{{customerInfo.applyDate}}</label>
					</el-col>
					<el-col :span="8" class="info-label">
						车型：
						<label class="text">{{customerInfo.carModel}}</label>
					</el-col>
				</el-row>
				<el-row class="info-row">
					<el-col :span="8" class="info-label">
						贷款额度：
						<label class="text">{{customerInfo.loanPrice}}</label>
					</el-col>
				</el-row>
			</div>
			<div class="title">通融内容</div>
			<div class="infoContent">
				<el-row class="info-row">
					<el-col :span="8" class="info-label">
						修改人：
						<label class="text">{{exceptionInfo.person}}</label>
					</el-col>
					<el-col :span="8" class="info-label">
						修改日期：
						<label class="text">{{exceptionInfo.date}}</label>
					</el-col>
					<el-col :span="8" class="info-label">
						<el-button type="text" @click="infoAdd" v-show="$store.state.power!='ROLE_SALESMANAGER'">查看补录资料</el-button>
					</el-col>
				</el-row>
				<el-row class="info-row resultShrink">
					<el-col class="subtitle" :span="3">通融原因</el-col>
					<el-col :span="12" class="text-height text-height-shrink" id='checkExceptionResult'>
						{{ exceptionInfo.result }}
					</el-col>
					<el-col :span="3">
						<el-button class="credit-button-text" type="text" @click="$libs.changeHeight('checkExceptionResult', exceptionInfo)">{{ exceptionInfo.shrinkText}}</el-button>
					</el-col>
				</el-row>
			</div>
			<div class="title">审核</div>
			<div class="infoContent">
				<el-row class="info-row">
					<el-col :span="2" class="subTitle">
						审核意见
					</el-col>
					<el-col :span="22">
						<el-input class="info-textarea" :rows="3" type="textarea" placeholder="请输入" v-model="checkInfo.suggess"></el-input>
					</el-col>
				</el-row>
				<el-row class="info-row" v-show="isGpsShow">
					<el-col :span="2" class="subTitle">
						GPS
					</el-col>
					<el-col :span="18" class="radioContent">
						<el-radio class="radio" v-model="checkInfo.isGps" label='true'>需要</el-radio>
						<el-radio class="radio" v-model="checkInfo.isGps" label="false">不需要</el-radio>
					</el-col>
				</el-row>
				<el-row class="info-row">
					<el-col :span="2" class="subTitle">
						审核结果
					</el-col>
					<el-col :span="10" class="checkResult">
						<el-radio class="checkResult" v-model="checkInfo.result" label="1">同意</el-radio>
						<el-radio class="checkResult" v-model="checkInfo.result" label="0">不同意</el-radio>
						<el-radio v-show="power==1 && checkInfo.result == '0'" class="checkResult" v-model="checkInfo.result" label="3">附条件通过</el-radio>
					</el-col>
				</el-row>
			</div>
			<hr class="hr">
			<div>
				<el-button @click="cancal" type="cancal">取消</el-button>
				<el-button @click="submit" type="primary" :disabled="isFirstSubmit==true">提交</el-button>
			</div>
		</div>
		<el-dialog class="dialog-edit" size="large" title="补录资料" :visible.sync="supplementShow">
			<div class="gpsAddDialog">
				<el-row>
					<attachment ref="attachmentAdd"></attachment>
				</el-row>
			</div>
			<div class="dialog-footer" v-show="$store.state.power!='ROLE_AUDITORMANAGER'">
				<el-button type="primary" @click="supplementSave()">保存</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
export default {
	name: 'checkException',
	components: {
		steps: require('../../components/other/steps'),
		attachment: require('../../components/order/attachment')
	},
	data() {
		return {
			orderNo: this.$route.query.orderNo,
			orderStatus: this.$route.query.orderStatus,
			applyId: this.$route.query.applyId,
			applyType: this.$route.query.applyType,
			flowNodeId: this.$route.query.flowNodeId,
			taskId: this.$route.query.taskId,
			bizChannel: this.$route.query.bizChannel,
			annexBatchNo: this.$route.query.annexBatchNo,
			customerIdCard: this.$route.query.customerIdCard,
			isFirstSubmit: false,
			isGpsShow: true,
			power: this.$store.state.power == 'ROLE_AUDITORMANAGER' ? 1 : 0, //0业务经理/其它 1审核经理
			customerInfo: {
				orderNo: '', //订单编号
				salesman: '', //业务员
				salesmanUnit: '', //业务部门
				customer: '', //客户姓名
				applyDate: '', //申请日期
				carModel: '', //车型
				loanPrice: '', //贷款额度
			},
			exceptionInfo: {
				person: '', //修改人
				date: '', //修改日期
				result: '', //通融原因
				shrink: false,
				shrinkText: '展开全部'
			},
			checkInfo: {
				isGps: this.$route.query.needGps,
				suggess: '', //审核意见
				result: '', //审核结果
			},
			supplementShow: false, //补录资料
		}
	},
	methods: {
		cancal() {
			this.$confirm('是否确认取消?', '取消', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.$router.push({ path: '/check' });
			}).catch((error) => {});
		},
		infoAdd() {
			// 补充资料
			this.supplementShow = true;
			this.$nextTick(() => {
				this.$refs.attachmentAdd.isEdit = false;
				this.$refs.attachmentAdd.postDeal(this.orderNo, this.annexBatchNo);
			});
		},
		submit() {
			let param = {
				orderNo: this.orderNo,
				taskId: this.taskId,
				flowNodeId: this.flowNodeId,
				bizType: this.bizChannel,
				approvalResult: this.checkInfo.result,
				applyType: this.applyType,
				approvalRemark: this.checkInfo.suggess
			};
			if (param.approvalRemark.length > 200) {
				this.$message.error('审核意见字数过长，请控制在200字以内');
				return;
			}
			if (!this.$libs.mustWrite(param)) {
				this.$message('请把信息补充完整');
				return;
			}
			this.isFirstSubmit = true;
			if (!this.isGpsShow) {
				this.submitEnd(param);
				return;
			}
			this.$http.post('/submitTaskController/saveGPSInfo', {
				orderNo: this.orderNo,
				needGps: this.checkInfo.isGps == 'false' ? false : true
			}).then((data) => {
				if (data.data.success) {
					if (data.data.data == true) {
						this.submitEnd(param);
					} else {
						this.$message.error(data.data.message);
					}
				}
			}).catch((error) => {

			});
		},
		submitEnd(param) {
			this.$http.post('/submitTaskController/auditorSubmitTask', param).then((data) => {
				if (data.data.success) {
					this.$message({
						message: '审核成功！',
						type: 'success'
					});
					this.$router.push({ path: '/check' });
				} else {
					this.$message.error(data.data.message);
				}
			}).catch((error) => {

			});
		}
	},
	mounted() {
		this.$refs.steps.getCheckInfo(this.orderNo, this.orderStatus);

		this.$http.get('/submitTaskController/isShowGPS/' + this.orderNo).then((data) => {
			if (data.data.success) {
				this.isGpsShow = data.data.data;
			} else {
				this.$message.error(data.data.message);
			}
		}).catch((error) => {

		});

		this.$http.get('/audit/accomInfo/' + this.orderNo).then((data) => {
			if (data.data.success) {
				let datas = data.data.data;
				this.customerInfo = {
					orderNo: datas.orderNo, //订单编号
					salesman: datas.staffName, //业务员
					salesmanUnit: datas.deptName, //业务部门
					customer: datas.customerName, //客户姓名
					applyDate: datas.applyCreate, //申请日期
					carModel: datas.carModel, //车型
					loanPrice: datas.loanAmount, //贷款额度
				};

				this.exceptionInfo.person = datas.modifyStaffName;
				this.exceptionInfo.date = datas.modifyCreate;
				this.exceptionInfo.result = datas.remark;
			}
		}).catch((error) => {

		});
	}
}

</script>
<style type="text/css" lang="scss" scoped>
@import '../../assets/css/site.scss';
.checkException {
	padding: 10px 16px;
	position: relative;
	.info-content {
		background: #fff;
		padding: 20px;
		position: absolute;
		top: 50px;
		left: 16px;
		right: 16px;
		bottom: 0;
		padding-bottom: 60px;
		overflow-y: auto;
		.hr {
			margin: 20px 0px 30px 0px;
			border: none;
			border-bottom: 1px solid #d3dce6;
		}
		.infoContent {
			margin-right: 350px;
			color: #5e6d82;
			.checkResult {
				text-align: left;
				margin-left: 6px;
				margin-top: 3px;
			}
			.active {
				color: #20a0ff;
			}
			.radioContent {
				text-align: left;
				margin: 5px 0px 0px 12px;
			}
		}
	}
	.dialog-edit {
		hr {
			margin: 0px 0px 0px 0px;
			border: none;
			border-bottom: 1px solid #d3dce6;
		}

		.dialog-footer {
			text-align: center;
			padding-top: 10px;
			border-top: 1px solid #d3dce6;
			.tip {
				font-size: 12px;
				color: #ff4949;
				position: absolute;
				margin-left: 10px;
				line-height: 2.8;
			}
		}
	}
	.gpsAddDialog {
		padding: 0 150px;
		max-height: 500px;
		overflow: auto;
	}
}

</style>
